1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
| [liruilong@master ansible]$ cat install_flannel_check.yml - name: flannel config check hosts: all vars: nodes: nodes tasks: - block: - shell: ifconfig docker0 | head -2 register: out - debug: msg="{{out}}" - shell: docker rm -f {{inventory_hostname}} - shell: docker run -itd --name {{inventory_hostname}} centos register: out1 - debug: msg="{{out1}}" when: nodes in group_names - shell: ifconfig flannel.1 | head -2 register: out - debug: msg="{{out}}" [liruilong@master ansible]$ [liruilong@master ansible]$ ansible-playbook install_flannel_check.yml
PLAY [flannel config check] *************************************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************** ok: [master] ok: [node2] ok: [node1]
TASK [shell] **************************************************************************************************************************************************************************************************** skipping: [master] changed: [node2] changed: [node1]
TASK [debug] **************************************************************************************************************************************************************************************************** skipping: [master] ok: [node1] => { "msg": { "changed": true, "cmd": "ifconfig docker0 | head -2", "delta": "0:00:00.021769", "end": "2021-09-12 21:51:44.826682", "failed": false, "rc": 0, "start": "2021-09-12 21:51:44.804913", "stderr": "", "stderr_lines": [], "stdout": "docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450\n inet 10.254.97.1 netmask 255.255.255.0 broadcast 0.0.0.0", "stdout_lines": [ "docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450", " inet 10.254.97.1 netmask 255.255.255.0 broadcast 0.0.0.0" ] } } ok: [node2] => { "msg": { "changed": true, "cmd": "ifconfig docker0 | head -2", "delta": "0:00:00.011223", "end": "2021-09-12 21:51:44.807988", "failed": false, "rc": 0, "start": "2021-09-12 21:51:44.796765", "stderr": "", "stderr_lines": [], "stdout": "docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450\n inet 10.254.59.1 netmask 255.255.255.0 broadcast 0.0.0.0", "stdout_lines": [ "docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450", " inet 10.254.59.1 netmask 255.255.255.0 broadcast 0.0.0.0" ] } }
TASK [shell] **************************************************************************************************************************************************************************************************** skipping: [master] changed: [node1] changed: [node2]
TASK [shell] **************************************************************************************************************************************************************************************************** skipping: [master] changed: [node1] changed: [node2]
TASK [debug] **************************************************************************************************************************************************************************************************** skipping: [master] ok: [node1] => { "msg": { "changed": true, "cmd": "docker run -itd --name node1 centos", "delta": "0:00:00.795119", "end": "2021-09-12 21:51:48.157221", "failed": false, "rc": 0, "start": "2021-09-12 21:51:47.362102", "stderr": "", "stderr_lines": [], "stdout": "1c0628dcb7e772640d9eb58179efc03533e796989f7a802e230f9ebc3012845a", "stdout_lines": [ "1c0628dcb7e772640d9eb58179efc03533e796989f7a802e230f9ebc3012845a" ] } } ok: [node2] => { "msg": { "changed": true, "cmd": "docker run -itd --name node2 centos", "delta": "0:00:00.787663", "end": "2021-09-12 21:51:48.194065", "failed": false, "rc": 0, "start": "2021-09-12 21:51:47.406402", "stderr": "", "stderr_lines": [], "stdout": "1931d80f5bfffc23fef714a58ab5b009ed5e2182199b55038bb9b1ccc69ec271", "stdout_lines": [ "1931d80f5bfffc23fef714a58ab5b009ed5e2182199b55038bb9b1ccc69ec271" ] } }
TASK [shell] **************************************************************************************************************************************************************************************************** changed: [master] changed: [node2] changed: [node1]
TASK [debug] **************************************************************************************************************************************************************************************************** ok: [master] => { "msg": { "changed": true, "cmd": "ifconfig flannel.1 | head -2", "delta": "0:00:00.011813", "end": "2021-09-12 21:51:48.722196", "failed": false, "rc": 0, "start": "2021-09-12 21:51:48.710383", "stderr": "", "stderr_lines": [], "stdout": "flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450\n inet 10.254.68.0 netmask 255.255.255.255 broadcast 0.0.0.0", "stdout_lines": [ "flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450", " inet 10.254.68.0 netmask 255.255.255.255 broadcast 0.0.0.0" ] } } ok: [node1] => { "msg": { "changed": true, "cmd": "ifconfig flannel.1 | head -2", "delta": "0:00:00.021717", "end": "2021-09-12 21:51:49.443800", "failed": false, "rc": 0, "start": "2021-09-12 21:51:49.422083", "stderr": "", "stderr_lines": [], "stdout": "flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450\n inet 10.254.97.0 netmask 255.255.255.255 broadcast 0.0.0.0", "stdout_lines": [ "flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450", " inet 10.254.97.0 netmask 255.255.255.255 broadcast 0.0.0.0" ] } } ok: [node2] => { "msg": { "changed": true, "cmd": "ifconfig flannel.1 | head -2", "delta": "0:00:00.012259", "end": "2021-09-12 21:51:49.439005", "failed": false, "rc": 0, "start": "2021-09-12 21:51:49.426746", "stderr": "", "stderr_lines": [], "stdout": "flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450\n inet 10.254.59.0 netmask 255.255.255.255 broadcast 0.0.0.0", "stdout_lines": [ "flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450", " inet 10.254.59.0 netmask 255.255.255.255 broadcast 0.0.0.0" ] } }
PLAY RECAP ****************************************************************************************************************************************************************************************************** master : ok=3 changed=1 unreachable=0 failed=0 skipped=5 rescued=0 ignored=0 node1 : ok=8 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 node2 : ok=8 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[liruilong@master ansible]$
|